import { defineStore } from 'pinia'
import { ref } from 'vue'
import type { User } from '@/types/user'

export const useUserStore = defineStore(
  'medical_user',
  () => {
    // 1. 用户信息状态
    const user = ref<User>()
    // 2. 设置用户信息函数
    const setUser = (userInfo: User) => {
      user.value = userInfo
    }
    // 3. 删除用户信息函数
    const delUser = () => {
      user.value = undefined
    }

    return {
      user,
      setUser,
      delUser
    }
  },
  {
    persist: true
  }
)
